<?php
/*
+ ---------------------------------------------------------------------- +
| e107Shop - An e-commerce plugin for the e107 content management system |
|                                                                        |
| ByOrder Europe 2007-2008                                               |
| http://e107shop.com                                                    |
| patrick@byorder.nl                                                     |
|                                                                        |
| Released under the terms and conditions of the LGPL                    |
|                                                                        |
| $Revision: 1.0                                                         |
| $Date: 2008/08/20                                                      |
| $Author: Bieleke                                                       |
+ ---------------------------------------------------------------------- +
*/

function e107shop_activate_gateway($gateway, $event) {
    global $e107shop_db_name, $tp;
    $sql=new db;
    // prevent SQL injection and XSS
    $gateway = $tp->toDB($gateway);
    
    // De-activate gateway
    if($event==0)
    {
        // Mark the gateway as in-active in the database
        if($sql->db_Select($e107shop_db_name['gateways'], "*", "identifier='".$gateway."' and active=1")){
            $sql->db_Update($e107shop_db_name['gateways'], "active='0' where identifier='".$gateway."'");
            return true;
        }
    }
    // Activate gateway
    if($event==1)
    {
        // Mark the gateway as active in the database
        if($sql->db_Select($e107shop_db_name['gateways'], "*", "identifier='".$gateway."' and active=0")){
            $sql->db_Update($e107shop_db_name['gateways'], "active='1' where identifier='".$gateway."'");
            return true;
        }
    }
    return false;
}

function e107shop_process_gateway_update($gateway, $gateway_account, $f1, $f2, $f3, $f4, $f5, $f6, $f7, $f8, $gateway_class)
{
    global $e107shop_db_name, $ns, $sql;
    $sql = new db;
    
    $sql->db_Update($e107shop_db_name['gateways'], "account='".$gateway_account."', field1='".$f1."', field2='".
    $f2."', field3='".$f3."', field4='".$f4."', field5='".$f5."', field6='".$f6."', field7='".$f7."', field8='".
    $f8."', gateway_class='".$gateway_class."' where identifier='".$gateway."'");
        
    $ns->tablerender("<center>".lan_global_status."</center>", 
    "<br /><center>".lan_gateway_update_text."</center><br />");
}

function e107shop_get_gateway($gateway, $field){
    global $e107shop_db_name;
    $sql = new db;
    $gateway = str_replace(".php", "", $gateway);
    $sql->db_Select($e107shop_db_name['gateways'], $field, "identifier='".$gateway."'");
        while($row = $sql->db_Fetch()){
            $field_data = $row[$field];
        }

    return $field_data;
}
